home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_03 / 1103097a < prev    next >
Text File  |  1993-01-03  |  1KB  |  46 lines

  1. // date6.h
  2.  
  3. class Date
  4. {
  5.     int month;
  6.     int day;
  7.     int year;
  8.  
  9. public:
  10.     // Constructors
  11.     Date()
  12.       {month = day = year = 0;}    
  13.     Date(int m, int d, int y)
  14.       {month = m; day = d; year = y;}
  15.  
  16.     // Accessor Functions
  17.     int get_month() const
  18.       {return month;}
  19.     int get_day() const
  20.       {return day;}
  21.     int get_year() const
  22.       {return year;}
  23.  
  24.     Date operator-(const Date& d2) const;
  25.     Date& operator-()
  26.       {month = -month; day = -day; year = -year;
  27.        return *this;}
  28.  
  29.     int compare(const Date&) const;
  30.  
  31.     // Relational operators
  32.     int operator<(const Date& d2) const
  33.       {return compare(d2) < 0;}
  34.     int operator<=(const Date& d2) const
  35.       {return compare(d2) <= 0;}
  36.     int operator>(const Date& d2) const
  37.       {return compare(d2) > 0;}
  38.     int operator>=(const Date& d2) const
  39.       {return compare(d2) >= 0;}
  40.     int operator==(const Date& d2) const
  41.       {return compare(d2) == 0;}
  42.     int operator!=(const Date& d2) const
  43.       {return compare(d2) != 0;}
  44. };
  45.  
  46.